﻿using System;
using System.Data;
using System.Collections.Generic;
using ElingOA6_Admin_DSJCJ.Model;
namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// ItemRequisitionApplyEntry
    /// </summary>
    public partial class ItemRequisitionApplyEntry
    {
        private readonly ElingOA6_Admin_DSJCJ.DAL.ItemRequisitionApplyEntry dal = new ElingOA6_Admin_DSJCJ.DAL.ItemRequisitionApplyEntry();
        public ItemRequisitionApplyEntry()
        { }
        #region  BasicMethod
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.ItemRequisitionApplyEntry> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.ItemRequisitionApplyEntry> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.ItemRequisitionApplyEntry> modelList = new List<ElingOA6_Admin_DSJCJ.Model.ItemRequisitionApplyEntry>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.ItemRequisitionApplyEntry model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 获取明细数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-9-29</date>
        /// <param name="paperID">订单编号</param>
        /// <returns>List集合</returns>
        public List<Model.ItemRequisitionApplyEntry> GetListEntry(decimal itemRequisitionApplyID)
        {
            DataSet ds = dal.GetListEntry(itemRequisitionApplyID);
            List<Model.ItemRequisitionApplyEntry> entryModelList = new List<Model.ItemRequisitionApplyEntry>();
            DataTable dt = ds.Tables[0];
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.ItemRequisitionApplyEntry model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.ItemRequisitionApplyEntry();
                    if (dt.Rows[n]["FItemRequisitionApplyEntryID"] != null && dt.Rows[n]["FItemRequisitionApplyEntryID"].ToString() != "")
                    {
                        model.FItemRequisitionApplyEntryID = int.Parse(dt.Rows[n]["FItemRequisitionApplyEntryID"].ToString());
                    }
                    if (dt.Rows[n]["FItemRequisitionApplyID"] != null && dt.Rows[n]["FItemRequisitionApplyID"].ToString() != "")
                    {
                        model.FItemRequisitionApplyID = int.Parse(dt.Rows[n]["FItemRequisitionApplyID"].ToString());
                    }
                    if (dt.Rows[n]["FItemNo"] != null && dt.Rows[n]["FItemNo"].ToString() != "")
                    {
                        model.FItemNo = dt.Rows[n]["FItemNo"].ToString();
                    }
                    if (dt.Rows[n]["FQty"] != null && dt.Rows[n]["FQty"].ToString() != "")
                    {
                        model.FQty = decimal.Parse(dt.Rows[n]["FQty"].ToString());
                    }
                    if (dt.Rows[n]["FPrice"] != null && dt.Rows[n]["FPrice"].ToString() != "")
                    {
                        model.FPrice = decimal.Parse(dt.Rows[n]["FPrice"].ToString());
                    }
                    if (dt.Rows[n]["FAmount"] != null && dt.Rows[n]["FAmount"].ToString() != "")
                    {
                        model.FAmount = decimal.Parse(dt.Rows[n]["FAmount"].ToString());
                    }

                    entryModelList.Add(model);
                }

            }

            return entryModelList;

        }

        #endregion  BasicMethod
        #region  ExtensionMethod

        #endregion  ExtensionMethod
    }
}

